Socket
Socket
Sign inDemoInstall

@griffel/react

Package Overview
Dependencies
Maintainers
6
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@griffel/react

React implementation of Atomic CSS-in-JS


Version published
Weekly downloads
105K
decreased by-13.27%
Maintainers
6
Weekly downloads
 
Created

What is @griffel/react?

@griffel/react is a CSS-in-JS library designed to provide a performant and flexible way to style React components. It focuses on runtime performance and developer experience, offering features like atomic CSS, theming, and server-side rendering support.

What are @griffel/react's main functionalities?

Atomic CSS

Griffel generates atomic CSS classes for each style rule, ensuring minimal CSS output and better performance.

const useStyles = makeStyles({
  root: { color: 'red' },
  button: { backgroundColor: 'blue' }
});

function MyComponent() {
  const classes = useStyles();
  return (
    <div className={classes.root}>
      <button className={classes.button}>Click me</button>
    </div>
  );
}

Theming

Griffel supports theming, allowing you to define and use theme variables throughout your application.

const theme = {
  color: 'blue',
  background: 'lightgray'
};

const useStyles = makeStyles({
  root: theme => ({
    color: theme.color,
    backgroundColor: theme.background
  })
});

function MyComponent() {
  const classes = useStyles(theme);
  return <div className={classes.root}>Themed Component</div>;
}

Server-Side Rendering

Griffel supports server-side rendering, ensuring that styles are correctly rendered on the server and sent to the client.

import { renderToString } from 'react-dom/server';
import { GriffelProvider, makeStyles } from '@griffel/react';

const useStyles = makeStyles({
  root: { color: 'red' }
});

function MyComponent() {
  const classes = useStyles();
  return <div className={classes.root}>Hello SSR</div>;
}

const html = renderToString(
  <GriffelProvider>
    <MyComponent />
  </GriffelProvider>
);

Other packages similar to @griffel/react

FAQs

Package last updated on 29 Jul 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc